package services.freenas

import com.typesafe.config.Config
import play.api.ConfigLoader

case class FreeNASConfig(url:String="",user:String="",password:String="",apikey:String="",gid:Int=0)

object FreeNASConfig {
  implicit val configLoader:ConfigLoader[FreeNASConfig] = new ConfigLoader[FreeNASConfig] {
    override def load(config: Config, path: String): FreeNASConfig = {
      val conf = if (path.isEmpty){
        config.getConfig("freenas.config.default")
      }else{
        config.getConfig("freenas.config."+path)
      }
      FreeNASConfig(
        url = conf.getString("url"),
        user = conf.getString("user"),
        password = conf.getString("password"),
        apikey = conf.getString("ApiKey"),
        gid = conf.getInt("gid")
      )
    }
  }
}
